﻿#pragma once

#include "../../Server/Settings.h"
#include "../../Server/MirEnvir/Envir.h"
#include "../../Shared/Data/ItemData.h"
#include <string>
#include <vector>
#include <any>

using namespace Server::MirEnvir;

namespace Server
{
    class ItemInfoForm : public System::Windows::Forms::Form
    {
    public:
        std::string ItemListPath = Path::Combine(Settings::ExportPath, "ItemList.txt");

        virtual ~ItemInfoForm()
        {
            delete components;
            delete ItemInfoPanel;
            delete WWeightTextBox;
            delete label32;
            delete HWeightTextBox;
            delete label30;
            delete BWeightText;
            delete label31;
            delete StartItemCheckBox;
            delete LuckTextBox;
            delete label28;
            delete ASpeedTextBox;
            delete label29;
            delete AgilityTextBox;
            delete label26;
            delete AccuracyTextBox;
            delete label27;
            delete MPTextBox;
            delete label24;
            delete HPTextBox;
            delete label25;
            delete MaxSCTextBox;
            delete label22;
            delete MinSCTextBox;
            delete label23;
            delete MaxMCTextBox;
            delete label18;
            delete MinMCTextBox;
            delete label19;
            delete MaxDCTextBox;
            delete label20;
            delete MinDCTextBox;
            delete label21;
            delete MaxMACTextBox;
            delete label16;
            delete MinMACTextBox;
            delete label17;
            delete MaxACTextBox;
            delete label15;
            delete MinACTextBox;
            delete label14;
            delete PriceTextBox;
            delete label13;
            delete SSizeTextBox;
            delete label12;
            delete ImageTextBox;
            delete label10;
            delete DuraTextBox;
            delete label11;
            delete LightTextBox;
            delete label9;
            delete WeightTextBox;
            delete label8;
            delete ShapeTextBox;
            delete label7;
            delete RAmountTextBox;
            delete label6;
            delete RClassComboBox;
            delete label5;
            delete RTypeComboBox;
            delete label4;
            delete ITypeComboBox;
            delete label2;
            delete ItemNameTextBox;
            delete label3;
            delete ItemIndexTextBox;
            delete label1;
            delete RemoveButton;
            delete AddButton;
            delete ItemInfoListBox;
            delete RGenderComboBox;
            delete label33;
            delete PasteButton;
            delete CopyMButton;
            delete EffectTextBox;
            delete label34;
            delete ITypeFilterComboBox;
            delete ExportAllButton;
            delete ExportSelectedButton;
            delete ImportButton;
            delete label35;
            delete ISetComboBox;
            delete PoisonRecoverytextBox;
            delete label43;
            delete SpellRecoverytextBox;
            delete label42;
            delete PoisonResisttextBox;
            delete label41;
            delete MagicResisttextBox;
            delete label40;
            delete HealthRecoveryTextbox;
            delete label39;
            delete StrongTextbox;
            delete label38;
            delete MacRateTextbox;
            delete label37;
            delete ACRateTextbox;
            delete label36;
            delete Bind_dontstorecheckbox;
            delete Bind_dontupgradecheckbox;
            delete Bind_dontrepaircheckbox;
            delete Bind_donttradecheckbox;
            delete Bind_dontsellcheckbox;
            delete Bind_destroyondropcheckbox;
            delete Bind_dontdeathdropcheckbox;
            delete Bind_dontdropcheckbox;
            delete LevelBasedcheckbox;
            delete ClassBasedcheckbox;
            delete PoisonAttacktextbox;
            delete label47;
            delete Freezingtextbox;
            delete label46;
            delete Holytextbox;
            delete label45;
            delete HPratetextbox;
            delete label44;
            delete BindOnEquipcheckbox;
            delete ShowGroupPickupcheckbox;
            delete NeedIdentifycheckbox;
            delete MPratetextbox;
            delete label48;
            delete HpDrainRatetextBox;
            delete label49;
            delete tabControl1;
            delete tabPage1;
            delete tabPage2;
            delete tabPage3;
            delete tabPage4;
            delete NoDuraLosscheckBox;
            delete SkillcheckBox;
            delete ProbecheckBox;
            delete HealingcheckBox;
            delete FlamecheckBox;
            delete MusclecheckBox;
            delete RevivalcheckBox;
            delete ProtectioncheckBox;
            delete ClearcheckBox;
            delete TeleportcheckBox;
            delete ParalysischeckBox;
            delete label50;
            delete CriticalRatetextBox;
            delete label51;
            delete CriticalDamagetextBox;
            delete groupBox1;
            delete label52;
            delete ReflecttextBox;
            delete Bind_DontSpecialRepaircheckBox;
            delete LightIntensitytextBox;
            delete label53;
            delete RandomStatstextBox;
            delete label54;
            delete PickaxecheckBox;
            delete label55;
            delete IGradeComboBox;
            delete FastRunCheckBox;
            delete label56;
            delete TooltipTextBox;
            delete CanAwaken;
            delete BreakOnDeathcheckbox;
            delete Gameshop_button;
            delete NoWeddingRingcheckbox;
            delete unableToRent_CheckBox;
            delete unableToDisassemble_CheckBox;
            delete globalDropNotify_CheckBox;
            delete BlinkcheckBox;
            delete noMailBox;
            delete SlotsTextBox;
            delete label57;
        }

        Server::MirEnvir::Envir *getEnvir() const;
    private:
        std::vector<ItemInfo*> _selectedItemInfos;

    public:
        class ComboBoxItem
        {
        private:
            std::string Text;
            std::any Value;

        public:
            std::string getText() const;
            void setText(const std::string &value);
            std::any getValue() const;
            void setValue(const std::any &value);

            std::string ToString();
        };

    public:
        ItemInfoForm();

        void RefreshUniqueTab();

        void UpdateInterface(bool refreshList = false);

    private:
        void RefreshItemList();

        void AddButton_Click(std::any sender, EventArgs *e);

        void ItemInfoListBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void ITypeFilterComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void RemoveButton_Click(std::any sender, EventArgs *e);
        void ItemNameTextBox_TextChanged(std::any sender, EventArgs *e);
        void ITypeComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void RTypeComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void RGenderComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void RClassComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);
        void StartItemCheckBox_CheckedChanged(std::any sender, EventArgs *e);
        void WeightTextBox_TextChanged(std::any sender, EventArgs *e);
        void ImageTextBox_TextChanged(std::any sender, EventArgs *e);
        void DuraTextBox_TextChanged(std::any sender, EventArgs *e);
        void ShapeTextBox_TextChanged(std::any sender, EventArgs *e);
        void SSizeTextBox_TextChanged(std::any sender, EventArgs *e);
        void PriceTextBox_TextChanged(std::any sender, EventArgs *e);
        void RAmountTextBox_TextChanged(std::any sender, EventArgs *e);
        void LightTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinACTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxACTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinMACTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxMACTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinDCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxDCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinMCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxMCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MinSCTextBox_TextChanged(std::any sender, EventArgs *e);
        void MaxSCTextBox_TextChanged(std::any sender, EventArgs *e);
        void HPTextBox_TextChanged(std::any sender, EventArgs *e);
        void MPTextBox_TextChanged(std::any sender, EventArgs *e);
        void AccuracyTextBox_TextChanged(std::any sender, EventArgs *e);
        void AgilityTextBox_TextChanged(std::any sender, EventArgs *e);
        void ASpeedTextBox_TextChanged(std::any sender, EventArgs *e);
        void LuckTextBox_TextChanged(std::any sender, EventArgs *e);
        void BWeightText_TextChanged(std::any sender, EventArgs *e);
        void HWeightTextBox_TextChanged(std::any sender, EventArgs *e);
        void WWeightTextBox_TextChanged(std::any sender, EventArgs *e);
        void EffectTextBox_TextChanged(std::any sender, EventArgs *e);

        void ItemInfoForm_FormClosed(std::any sender, FormClosedEventArgs *e);

        void PasteButton_Click(std::any sender, EventArgs *e);

        void CopyMButton_Click(std::any sender, EventArgs *e);

        void ExportAllButton_Click(std::any sender, EventArgs *e);

        void ExportSelectedButton_Click(std::any sender, EventArgs *e);

        void ExportItems(std::vector<ItemInfo*> &items);

        void ImportButton_Click(std::any sender, EventArgs *e);

        void ISetComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void ACRateTextbox_TextChanged(std::any sender, EventArgs *e);

        void MacRateTextbox_TextChanged(std::any sender, EventArgs *e);

        void MagicResisttextBox_TextChanged(std::any sender, EventArgs *e);

        void PoisonResisttextBox_TextChanged(std::any sender, EventArgs *e);

        void HealthRecoveryTextbox_TextChanged(std::any sender, EventArgs *e);

        void SpellRecoverytextBox_TextChanged(std::any sender, EventArgs *e);

        void PoisonRecoverytextBox_TextChanged(std::any sender, EventArgs *e);

        void HporMpRatetextbox_TextChanged(std::any sender, EventArgs *e);

        void Holytextbox_TextChanged(std::any sender, EventArgs *e);

        void Freezingtextbox_TextChanged(std::any sender, EventArgs *e);

        void PoisonAttacktextbox_TextChanged(std::any sender, EventArgs *e);

        void ClassBasedcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void LevelBasedcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void Bind_dontdropcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void Bind_dontdeathdropcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void Bind_destroyondropcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void Bind_dontsellcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void Bind_donttradecheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void Bind_dontrepaircheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void Bind_dontstorecheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void Bind_dontupgradecheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void NeedIdentifycheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void ShowGroupPickupcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void BindOnEquipcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void MPratetextBox_TextChanged(std::any sender, EventArgs *e);

        void HpDrainRatetextBox_TextChanged(std::any sender, EventArgs *e);


        void ParalysischeckBox_CheckedChanged(std::any sender, EventArgs *e);

        void TeleportcheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void ClearcheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void ProtectioncheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void RevivalcheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void MusclecheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void FlamecheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void HealingcheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void ProbecheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void SkillcheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void NoDuraLosscheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void StrongTextbox_TextChanged(std::any sender, EventArgs *e);

        void CriticalRatetextBox_TextChanged(std::any sender, EventArgs *e);

        void CriticalDamagetextBox_TextChanged(std::any sender, EventArgs *e);

        void ReflecttextBox_TextChanged(std::any sender, EventArgs *e);

        void Bind_DontSpecialRepaircheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void BlinkcheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void LightIntensitytextBox_TextChanged(std::any sender, EventArgs *e);

        void RandomStatstextBox_TextChanged(std::any sender, EventArgs *e);

        void PickaxecheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void IGradeComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void FastRunCheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void TooltipTextBox_TextChanged(std::any sender, EventArgs *e);

        void CanAwakening_CheckedChanged(std::any sender, EventArgs *e);

        void BreakOnDeathcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void ItemInfoForm_Load(std::any sender, EventArgs *e);

        void Gameshop_button_Click(std::any sender, EventArgs *e);

        void NoWeddingRingcheckbox_CheckedChanged(std::any sender, EventArgs *e);

        void unableToRent_CheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void unableToDisassemble_CheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void globalDropNotify_CheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void noMailBox_CheckedChanged(std::any sender, EventArgs *e);

        void SlotsTextBox_TextChanged(std::any sender, EventArgs *e);


        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::IContainer *components = nullptr;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected:
        void Dispose(bool disposing) override;

        #pragma region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
    private:
        void InitializeComponent();

        #pragma endregion

        System::Windows::Forms::Panel *ItemInfoPanel;
        System::Windows::Forms::TextBox *WWeightTextBox;
        System::Windows::Forms::Label *label32;
        System::Windows::Forms::TextBox *HWeightTextBox;
        System::Windows::Forms::Label *label30;
        System::Windows::Forms::TextBox *BWeightText;
        System::Windows::Forms::Label *label31;
        System::Windows::Forms::CheckBox *StartItemCheckBox;
        System::Windows::Forms::TextBox *LuckTextBox;
        System::Windows::Forms::Label *label28;
        System::Windows::Forms::TextBox *ASpeedTextBox;
        System::Windows::Forms::Label *label29;
        System::Windows::Forms::TextBox *AgilityTextBox;
        System::Windows::Forms::Label *label26;
        System::Windows::Forms::TextBox *AccuracyTextBox;
        System::Windows::Forms::Label *label27;
        System::Windows::Forms::TextBox *MPTextBox;
        System::Windows::Forms::Label *label24;
        System::Windows::Forms::TextBox *HPTextBox;
        System::Windows::Forms::Label *label25;
        System::Windows::Forms::TextBox *MaxSCTextBox;
        System::Windows::Forms::Label *label22;
        System::Windows::Forms::TextBox *MinSCTextBox;
        System::Windows::Forms::Label *label23;
        System::Windows::Forms::TextBox *MaxMCTextBox;
        System::Windows::Forms::Label *label18;
        System::Windows::Forms::TextBox *MinMCTextBox;
        System::Windows::Forms::Label *label19;
        System::Windows::Forms::TextBox *MaxDCTextBox;
        System::Windows::Forms::Label *label20;
        System::Windows::Forms::TextBox *MinDCTextBox;
        System::Windows::Forms::Label *label21;
        System::Windows::Forms::TextBox *MaxMACTextBox;
        System::Windows::Forms::Label *label16;
        System::Windows::Forms::TextBox *MinMACTextBox;
        System::Windows::Forms::Label *label17;
        System::Windows::Forms::TextBox *MaxACTextBox;
        System::Windows::Forms::Label *label15;
        System::Windows::Forms::TextBox *MinACTextBox;
        System::Windows::Forms::Label *label14;
        System::Windows::Forms::TextBox *PriceTextBox;
        System::Windows::Forms::Label *label13;
        System::Windows::Forms::TextBox *SSizeTextBox;
        System::Windows::Forms::Label *label12;
        System::Windows::Forms::TextBox *ImageTextBox;
        System::Windows::Forms::Label *label10;
        System::Windows::Forms::TextBox *DuraTextBox;
        System::Windows::Forms::Label *label11;
        System::Windows::Forms::TextBox *LightTextBox;
        System::Windows::Forms::Label *label9;
        System::Windows::Forms::TextBox *WeightTextBox;
        System::Windows::Forms::Label *label8;
        System::Windows::Forms::TextBox *ShapeTextBox;
        System::Windows::Forms::Label *label7;
        System::Windows::Forms::TextBox *RAmountTextBox;
        System::Windows::Forms::Label *label6;
        System::Windows::Forms::ComboBox *RClassComboBox;
        System::Windows::Forms::Label *label5;
        System::Windows::Forms::ComboBox *RTypeComboBox;
        System::Windows::Forms::Label *label4;
        System::Windows::Forms::ComboBox *ITypeComboBox;
        System::Windows::Forms::Label *label2;
        System::Windows::Forms::TextBox *ItemNameTextBox;
        System::Windows::Forms::Label *label3;
        System::Windows::Forms::TextBox *ItemIndexTextBox;
        System::Windows::Forms::Label *label1;
        System::Windows::Forms::Button *RemoveButton;
        System::Windows::Forms::Button *AddButton;
        System::Windows::Forms::ListBox *ItemInfoListBox;
        System::Windows::Forms::ComboBox *RGenderComboBox;
        System::Windows::Forms::Label *label33;
        System::Windows::Forms::Button *PasteButton;
        System::Windows::Forms::Button *CopyMButton;
        System::Windows::Forms::TextBox *EffectTextBox;
        System::Windows::Forms::Label *label34;
        System::Windows::Forms::ComboBox *ITypeFilterComboBox;
        System::Windows::Forms::Button *ExportAllButton;
        System::Windows::Forms::Button *ExportSelectedButton;
        System::Windows::Forms::Button *ImportButton;
        System::Windows::Forms::Label *label35;
        System::Windows::Forms::ComboBox *ISetComboBox;
        System::Windows::Forms::TextBox *PoisonRecoverytextBox;
        System::Windows::Forms::Label *label43;
        System::Windows::Forms::TextBox *SpellRecoverytextBox;
        System::Windows::Forms::Label *label42;
        System::Windows::Forms::TextBox *PoisonResisttextBox;
        System::Windows::Forms::Label *label41;
        System::Windows::Forms::TextBox *MagicResisttextBox;
        System::Windows::Forms::Label *label40;
        System::Windows::Forms::TextBox *HealthRecoveryTextbox;
        System::Windows::Forms::Label *label39;
        System::Windows::Forms::TextBox *StrongTextbox;
        System::Windows::Forms::Label *label38;
        System::Windows::Forms::TextBox *MacRateTextbox;
        System::Windows::Forms::Label *label37;
        System::Windows::Forms::TextBox *ACRateTextbox;
        System::Windows::Forms::Label *label36;
        System::Windows::Forms::CheckBox *Bind_dontstorecheckbox;
        System::Windows::Forms::CheckBox *Bind_dontupgradecheckbox;
        System::Windows::Forms::CheckBox *Bind_dontrepaircheckbox;
        System::Windows::Forms::CheckBox *Bind_donttradecheckbox;
        System::Windows::Forms::CheckBox *Bind_dontsellcheckbox;
        System::Windows::Forms::CheckBox *Bind_destroyondropcheckbox;
        System::Windows::Forms::CheckBox *Bind_dontdeathdropcheckbox;
        System::Windows::Forms::CheckBox *Bind_dontdropcheckbox;
        System::Windows::Forms::CheckBox *LevelBasedcheckbox;
        System::Windows::Forms::CheckBox *ClassBasedcheckbox;
        System::Windows::Forms::TextBox *PoisonAttacktextbox;
        System::Windows::Forms::Label *label47;
        System::Windows::Forms::TextBox *Freezingtextbox;
        System::Windows::Forms::Label *label46;
        System::Windows::Forms::TextBox *Holytextbox;
        System::Windows::Forms::Label *label45;
        System::Windows::Forms::TextBox *HPratetextbox;
        System::Windows::Forms::Label *label44;
        System::Windows::Forms::CheckBox *BindOnEquipcheckbox;
        System::Windows::Forms::CheckBox *ShowGroupPickupcheckbox;
        System::Windows::Forms::CheckBox *NeedIdentifycheckbox;
        System::Windows::Forms::TextBox *MPratetextbox;
        System::Windows::Forms::Label *label48;
        System::Windows::Forms::TextBox *HpDrainRatetextBox;
        System::Windows::Forms::Label *label49;
        System::Windows::Forms::TabControl *tabControl1;
        System::Windows::Forms::TabPage *tabPage1;
        System::Windows::Forms::TabPage *tabPage2;
        System::Windows::Forms::TabPage *tabPage3;
        System::Windows::Forms::TabPage *tabPage4;
        System::Windows::Forms::CheckBox *NoDuraLosscheckBox;
        System::Windows::Forms::CheckBox *SkillcheckBox;
        System::Windows::Forms::CheckBox *ProbecheckBox;
        System::Windows::Forms::CheckBox *HealingcheckBox;
        System::Windows::Forms::CheckBox *FlamecheckBox;
        System::Windows::Forms::CheckBox *MusclecheckBox;
        System::Windows::Forms::CheckBox *RevivalcheckBox;
        System::Windows::Forms::CheckBox *ProtectioncheckBox;
        System::Windows::Forms::CheckBox *ClearcheckBox;
        System::Windows::Forms::CheckBox *TeleportcheckBox;
        System::Windows::Forms::CheckBox *ParalysischeckBox;
        System::Windows::Forms::Label *label50;
        System::Windows::Forms::TextBox *CriticalRatetextBox;
        System::Windows::Forms::Label *label51;
        System::Windows::Forms::TextBox *CriticalDamagetextBox;
        System::Windows::Forms::GroupBox *groupBox1;
        System::Windows::Forms::Label *label52;
        System::Windows::Forms::TextBox *ReflecttextBox;
        System::Windows::Forms::CheckBox *Bind_DontSpecialRepaircheckBox;
        System::Windows::Forms::TextBox *LightIntensitytextBox;
        System::Windows::Forms::Label *label53;
        System::Windows::Forms::TextBox *RandomStatstextBox;
        System::Windows::Forms::Label *label54;
        System::Windows::Forms::CheckBox *PickaxecheckBox;
        System::Windows::Forms::Label *label55;
        System::Windows::Forms::ComboBox *IGradeComboBox;
        System::Windows::Forms::CheckBox *FastRunCheckBox;
        System::Windows::Forms::Label *label56;
        System::Windows::Forms::TextBox *TooltipTextBox;
        System::Windows::Forms::CheckBox *CanAwaken;
        System::Windows::Forms::CheckBox *BreakOnDeathcheckbox;
        System::Windows::Forms::Button *Gameshop_button;
        System::Windows::Forms::CheckBox *NoWeddingRingcheckbox;
        System::Windows::Forms::CheckBox *unableToRent_CheckBox;
        System::Windows::Forms::CheckBox *unableToDisassemble_CheckBox;
        System::Windows::Forms::CheckBox *globalDropNotify_CheckBox;
        System::Windows::Forms::CheckBox *BlinkcheckBox;
        System::Windows::Forms::CheckBox *noMailBox;
        System::Windows::Forms::TextBox *SlotsTextBox;
        System::Windows::Forms::Label *label57;
    };
}
